#pragma once

#include <functional>
#include <list>

namespace rewine
{

class Shelter {
public:
    using fnCallback = void();

private:
    bool m_Enabled;
    std::list<std::function<fnCallback>> m_Callbacks;

public:

    Shelter()
        : m_Enabled(true) {}

    ~Shelter() {
        if (m_Enabled) {
            for (auto& f : m_Callbacks) {
                f();
            }
        }
    }

    void toggle(bool bEnabled) {
        m_Enabled = bEnabled;
    }
    
    void add(const std::function<fnCallback> &f) {
        m_Callbacks.push_back(f);
    }
};

} // namespace rewine
